package com.woniuxy.businessassembly.dao;

import com.woniuxy.businessassembly.model.HotelInfo;
import com.woniuxy.businessassembly.model.HotelPolicy;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.woniuxy.hotel.form.PolicyForm;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author Kevin Kwok
 * @since 2021-05-24
 */
@Mapper
public interface HotelPolicyMapper extends BaseMapper<HotelPolicy> {
    /*根据酒店名查询酒店的id*/
    @Select("select * from hotel_info where hotel_name = #{hotelName}")
    HotelInfo queryByName(String hotelName);

    /*给指定的酒店发布酒店政策*/
    @Insert("insert into hotel_policy (hotel_id,carrying_pets,extra_bed,breakfast_served,breakfast_form,breakfast_price,breakfast_time,is_adult,payment_method) values(#{hotelId},#{carryingPets},#{extraBed},#{breakfastServed},#{breakfastForm},#{breakfastPrice},#{breakfastTime},#{isAdult},#{paymentMethod})")
    int publishPolicy(PolicyForm policyForm);

    /*查询酒店的政策*/
    @Select("select * from hotel_policy where hotel_id=#{hotelId}")
    HotelPolicy queryPolicy(Integer hotelId);

    /*修改酒店的政策*/
    @Update("update hotel_policy set carrying_pets = #{carryingPets},extra_bed=#{extraBed},breakfast_served=#{breakfastServed},breakfast_form=#{breakfastForm},breakfast_price=#{breakfastPrice},breakfast_time=#{breakfastTime},is_adult=#{isAdult},payment_method=#{paymentMethod} where hotel_id=#{hotelId}")
    int modifyPolicy(HotelPolicy hotelPolicy);
}
